#include<stdio.h>
int main()
{
    int n, m, i, j, count;
    char arr[101][101] = { 0 };
    scanf("%d%d", &n, &m);
    getchar();
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%c", &arr[i][j]);
        }
        getchar();
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            count = 0;
            if (arr[i][j] == '*')
            {
                printf("*");
                continue;
            }
            if (arr[i + 1][j] == '*')
                count++;
            if (arr[i - 1][j] == '*')
                count++;
            if (arr[i][j + 1] == '*')
                count++;
            if (arr[i][j - 1] == '*')
                count++;
            if (arr[i + 1][j + 1] == '*')
                count++;
            if (arr[i + 1][j - 1] == '*')
                count++;
            if (arr[i - 1][j + 1] == '*')
                count++;
            if (arr[i - 1][j - 1] == '*')
                count++;
            arr[i][j] = count;
            printf("%d", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}


